<template>
<div>
  <van-nav-bar title="就诊人管理" left-text="返回"
               left-arrow  @click-left="back"/>
  <div>
    <div>
      <van-notice-bar
          left-icon="volume-o"
          text="亲爱的，最多只能添加五个就诊人信息！"
      />
    </div>
    <van-cell-group inset>
      <van-cell v-for="p in patients" style="background-color: ghostwhite;border-radius: 10px;margin-top: 20px">
        <template #title>
          <label style="font-weight: bold;font-size: 20px">{{p.name}}</label>
          <label style="border-radius: 10px;background-color: gainsboro;padding: 5px;margin-left: 20px">{{p.type}}</label>
        </template>
        <template #value>
          <van-tag v-if="p.flag==1" type="success">默认</van-tag>
        </template>
        <template style="margin-top: 10px" #label>
          <label>就诊卡:{{p.no}}</label>
          <label style="margin-left: 8px">余额:{{p.money}}</label>
        </template>
      </van-cell>
    </van-cell-group>
    <van-button style="margin-top: 20px;width: 90%;margin-left: 5%" type="primary" block @click="tz">
      添加就诊人
    </van-button>
  </div>
</div>
</template>

<script setup>
import {ref,onMounted} from "vue";
import axios from "axios";
import {useStore} from 'vuex'
import {useRouter} from "vue-router";

const store=useStore()
const router = useRouter()
const patients=new ref([])

const ck=ref(true)
onMounted(()=>{
  //请求接口 axios
  axios.get("patient/my?uid="+store.state.user.id).then(res=>{
    if(res.data.code==0){
      patients.value=res.data.data;
    }
  });
})
const back=()=>{
  history.back();
}
const tz = () => {
  router.push("/addpatient")
}
</script>

<style scoped>

</style>
